#include "audioDao.h"

audioDao::audioDao(QString url)
{
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(url);
    if (!db.open()) {
        qDebug() << "Error: connection with database failed";
    } else {
        qDebug() << "Database: connection ok";
    }

}

void audioDao::add(QString name, QString path)
{
    QString operate = "INSERT INTO audio(name,path) VALUES('%1','%2')";
    operate = operate.arg(name).arg(path);
    query.exec(operate);
}

void audioDao::add(QString name, QString author, QString path, QString lrcPath)
{
    QString operate = "INSERT INTO audio(name,author,path,lrcPath) VALUES('%1','%2','%3','%4')";
    operate = operate.arg(name).arg(author).arg(path).arg(lrcPath);
    query.exec();
}

void audioDao::add(QString name, QString author, QString path)
{
    QString operate = "INSERT INTO audio(name,author,path,lrcPath) VALUES('%1','%2','%3')";
    operate = operate.arg(name).arg(author).arg(path);
    query.exec();
}

void audioDao::add1(QString name, QString path, QString lrcPath)
{
    QString operate = "INSERT INTO audio(name,path,lrcPath) VALUES('%1','%2','%3')";
    operate = operate.arg(name).arg(path).arg(lrcPath);
    query.exec();
}

void audioDao::del(QString id)
{

}

void audioDao::select()
{

}
